﻿'
' Will Strohl (will.strohl@gmail.com)
' http://www.willstrohl.com
'
'Copyright (c) 2011, Will Strohl
'All rights reserved.
'
'Redistribution and use in source and binary forms, with or without modification, are 
'permitted provided that the following conditions are met:
'
'Redistributions of source code must retain the above copyright notice, this list of 
'conditions and the following disclaimer.
'
'Redistributions in binary form must reproduce the above copyright notice, this list 
'of conditions and the following disclaimer in the documentation and/or other 
'materials provided with the distribution.
'
'Neither the name of Will Strohl nor the names of its contributors may be 
'used to endorse or promote products derived from this software without specific prior 
'written permission.
'
'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
'EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
'OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
'SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
'INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
'TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
'BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
'CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
'ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
'DAMAGE.
'

Imports System
Imports System.Data
Imports Microsoft.ApplicationBlocks.Data

Namespace WillStrohl.Modules.CodeCamp

    Public Class SqlDataProvider
        Inherits DataProvider

#Region " Private Members "

        Private _connectionString As String = String.Empty
        Private _databaseOwner As String
        Private _objectQualifier As String

        Private Const ModuleQualifier As String = "wns_CoCa_"
        '
        ' sproc names
        '

        Private Const c_AddCodeCamp As String = "AddCodeCamp"
        Private Const c_UpdateCodeCamp As String = "UpdateCodeCamp"
        Private Const c_DeleteCodeCamp As String = "DeleteCodeCamp"
        Private Const c_GetCodeCampById As String = "GetCodeCampById"
        Private Const c_GetCodeCampByModule As String = "GetCodeCampByModule"
        Private Const c_GetCodeCamps As String = "GetCodeCamps"
        Private Const c_GetCodeCampsFutureSorted As String = "GetCodeCampsFutureSorted"
        Private Const c_EnabledCodeCamp As String = "EnableCodeCamp"

        Private Const c_AddRegistration As String = "AddRegistration"
        Private Const c_UpdateRegistration As String = "UpdateRegistration"
        Private Const c_DeleteRegistration As String = "DeleteRegistration"
        Private Const c_GetRegistrationById As String = "GetRegistrationById"
        Private Const c_GetRegistrationByUser As String = "GetRegistrationByUser"
        Private Const c_GetRegistrations As String = "GetRegistrations"

        Private Const c_AddVolunteer As String = "AddVolunteer"
        Private Const c_UpdateVolunteer As String = "UpdateVolunteer"
        Private Const c_DeleteVolunteer As String = "DeleteVolunteer"
        Private Const c_GetVolunteer As String = "GetVolunteer"
        Private Const c_GetVolunteers As String = "GetVolunteers"

        Private Const c_AddVolunteerTask As String = "AddVolunteerTask"
        Private Const c_UpdateVolunteerTask As String = "UpdateVolunteerTask"
        Private Const c_DeleteVolunteerTask As String = "DeleteVolunteerTask"
        Private Const c_GetVolunteerTask As String = "GetVolunteerTask"
        Private Const c_GetVolunteerTasks As String = "GetVolunteerTasks"

        Private Const c_AddTimeSlot As String = "AddTimeSlot"
        Private Const c_UpdateTimeSlot As String = "UpdateTimeSlot"
        Private Const c_DeleteTimeSlot As String = "DeleteTimeSlot"
        Private Const c_GetTimeSlot As String = "GetTimeSlot"
        Private Const c_GetTimeSlots As String = "GetTimeSlots"

        Private Const c_AddSpeaker As String = "AddSpeaker"
        Private Const c_UpdateSpeaker As String = "UpdateSpeaker"
        Private Const c_DeleteSpeaker As String = "DeleteSpeaker"
        Private Const c_GetSpeaker As String = "GetSpeaker"
        Private Const c_GetSpeakerByUserId As String = "GetSpeakerByUserId"
        Private Const c_GetSpeakerByRegistrationId As String = "GetSpeakerByRegistrationId"
        Private Const c_GetSpeakersBySession As String = "GetSpeakersBySession"
        Private Const c_GetSpeakersByCodeCamp As String = "GetSpeakersByCodeCamp"
        Private Const c_GetSpeakersByCodeCampAll As String = "GetSpeakersByCodeCampAll"
        Private Const c_ApproveSpeaker As String = "ApproveSpeaker"

        Private Const c_AddTrack As String = "AddTrack"
        Private Const c_UpdateTrack As String = "UpdateTrack"
        Private Const c_DeleteTrack As String = "DeleteTrack"
        Private Const c_GetTrack As String = "GetTrack"
        Private Const c_GetTracks As String = "GetTracks"

        Private Const c_AddSession As String = "AddSession"
        Private Const c_AddSessionMinimal As String = "AddSessionMinimal"
        Private Const c_UpdateSessionMinimal As String = "UpdateSessionMinimal"
        Private Const c_UpdateSession As String = "UpdateSession"
        Private Const c_DeleteSession As String = "DeleteSession"
        Private Const c_GetSession As String = "GetSession"
        Private Const c_GetSessionsByTrack As String = "GetSessionsByTrack"
        Private Const c_GetSessionsBySpeakerId As String = "GetSessionsBySpeaker"
        Private Const c_GetSessionsByCodeCamp As String = "GetSessionsByCodeCamp"

        Private Const c_AddRoom As String = "AddRoom"
        Private Const c_UpdateRoom As String = "UpdateRoom"
        Private Const c_DeleteRoom As String = "DeleteRoom"
        Private Const c_GetRoom As String = "GetRoom"
        Private Const c_GetRoomsByCodeCamp As String = "GetRoomsByCodeCamp"

        Private Const c_CodeCampCount As String = "CodeCampCount"
        Private Const c_CodeCampRoomCount As String = "CodeCampRoomCount"
        Private Const c_CodeCampTrackCount As String = "CodeCampTrackCount"
        Private Const c_CodeCampAttendeeCount As String = "CodeCampAttendeeCount"
        Private Const c_CodeCampSpeakerCount As String = "CodeCampSpeakerCount"
        Private Const c_CodeCampSessionCount As String = "CodeCampSessionCount"
        Private Const c_SpeakerSessionCount As String = "SpeakerSessionCount"
        Private Const c_TrackSessionCount As String = "TrackSessionCount"
        Private Const c_CodeCampVolunteerCount As String = "CodeCampVolunteerCount"
        Private Const c_CodeCampVolunteerTaskCount As String = "CodeCampVolunteerTaskCount"

#End Region

#Region "Private Methods"

        Private Function GetFullyQualifiedName(ByVal name As String) As String
            Return String.Concat(DatabaseOwner, ObjectQualifier, ModuleQualifier, name)
        End Function

#End Region

#Region " Properties "

        Public Property ConnectionString() As String
            Set(ByVal value As String)
                _connectionString = value
            End Set
            Get
                If _connectionString = String.Empty Then
                    Return DotNetNuke.Data.DataProvider.Instance().ConnectionString
                Else
                    Return _connectionString
                End If
            End Get
        End Property

        Public Property DatabaseOwner() As String
            Set(ByVal value As String)
                _databaseOwner = value
            End Set
            Get
                If _databaseOwner = String.Empty Then
                    Return DotNetNuke.Data.DataProvider.Instance().DatabaseOwner
                Else
                    Return _databaseOwner
                End If
            End Get
        End Property

        Public Property ObjectQualifier() As String
            Set(ByVal value As String)
                _objectQualifier = value
            End Set
            Get
                If _objectQualifier = String.Empty Then
                    Return DotNetNuke.Data.DataProvider.Instance().ObjectQualifier
                Else
                    Return _objectQualifier
                End If
            End Get
        End Property

#End Region

#Region " Data Provider Implementation "

        Public Overrides Function AddCodeCamp(ByVal ModuleId As Integer, ByVal Title As String, ByVal Description As String, ByVal BeginDate As Date, ByVal EndDate As Date, ByVal IconFile As String, ByVal AltText As String, ByVal RoleName As String, ByVal WaitListRoleName As String, ByVal MaximumCapacity As Integer, ByVal RegistrationActive As Boolean, ByVal ShowShirtSize As Boolean, ByVal ShowMicrosoftMVP As Boolean, ByVal ShowAuthor As Boolean, ByVal CreatedByUser As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_AddCodeCamp), ModuleId, Title, Description, BeginDate, EndDate, IconFile, AltText, RoleName, WaitListRoleName, MaximumCapacity, RegistrationActive, ShowShirtSize, ShowMicrosoftMVP, ShowAuthor, CreatedByUser), Integer)
        End Function
        Public Overrides Sub DeleteCodeCamp(ByVal CodeCampId As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_DeleteCodeCamp), CodeCampId)
        End Sub
        Public Overrides Function GetCodeCampById(ByVal CodeCampId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetCodeCampById), CodeCampId), IDataReader)
        End Function
        Public Overrides Function GetCodeCampByModule(ByVal ModuleId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetCodeCampByModule), ModuleId), IDataReader)
        End Function
        Public Overrides Function GetCodeCamps() As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetCodeCamps)), IDataReader)
        End Function
        Public Overrides Function GetCodeCampsFutureSorted() As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetCodeCampsFutureSorted)), IDataReader)
        End Function
        Public Overrides Sub UpdateCodeCamp(ByVal CodeCampId As Integer, ByVal ModuleId As Integer, ByVal Title As String, ByVal Description As String, ByVal BeginDate As Date, ByVal EndDate As Date, ByVal IconFile As String, ByVal AltText As String, ByVal RoleName As String, ByVal WaitListRoleName As String, ByVal MaximumCapacity As Integer, ByVal NumberRegistered As Integer, ByVal EventFull As Boolean, ByVal RegistrationActive As Boolean, ByVal ShowShirtSize As Boolean, ByVal ShowMicrosoftMVP As Boolean, ByVal ShowAuthor As Boolean, ByVal CreatedByUser As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_UpdateCodeCamp), CodeCampId, ModuleId, Title, Description, BeginDate, EndDate, IconFile, AltText, RoleName, WaitListRoleName, MaximumCapacity, NumberRegistered, EventFull, RegistrationActive, ShowShirtSize, ShowMicrosoftMVP, ShowAuthor, CreatedByUser)
        End Sub
        Public Overrides Sub EnableCodeCamp(ByVal CodeCampId As Integer, ByVal Enable As Boolean)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_EnabledCodeCamp), CodeCampId, Enable)
        End Sub


        Public Overrides Function AddRegistration(ByVal CodeCampId As Integer, ByVal UserId As Integer, ByVal ShirtSize As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_AddRegistration), CodeCampId, UserId, ShirtSize), Integer)
        End Function
        Public Overrides Sub DeleteRegistration(ByVal RegistrationId As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_DeleteRegistration), RegistrationId)
        End Sub
        Public Overrides Function GetRegistrationById(ByVal RegistrationId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetRegistrationById), RegistrationId), IDataReader)
        End Function
        Public Overrides Function GetRegistrationByUser(ByVal UserId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetRegistrationByUser), UserId), IDataReader)
        End Function
        Public Overrides Function GetRegistrations(ByVal CodeCampId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetRegistrations), CodeCampId), IDataReader)
        End Function
        Public Overrides Sub UpdateRegistration(ByVal RegistrationId As Integer, ByVal CodeCampId As Integer, ByVal UserId As Integer, ByVal ShirtSize As String)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_UpdateRegistration), RegistrationId, CodeCampId, UserId, ShirtSize)
        End Sub


        Public Overrides Function AddRoom(ByVal CodeCampId As Integer, ByVal RoomName As String, ByVal Description As String, ByVal MaximumCapacity As Integer, ByVal CreatedByUser As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_AddRoom), CodeCampId, RoomName, Description, MaximumCapacity, CreatedByUser), Integer)
        End Function
        Public Overrides Sub DeleteRoom(ByVal RoomId As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_DeleteRoom), RoomId)
        End Sub
        Public Overrides Function GetRoom(ByVal RoomId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetRoom), RoomId), IDataReader)
        End Function
        Public Overrides Function GetRoomsByCodeCamp(ByVal CodeCampId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetRoomsByCodeCamp), CodeCampId), IDataReader)
        End Function
        Public Overrides Sub UpdateRoom(ByVal RoomId As Integer, ByVal CodeCampId As Integer, ByVal RoomName As String, ByVal Description As String, ByVal MaximumCapacity As Integer, ByVal CreatedByUser As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_UpdateRoom), RoomId, CodeCampId, RoomName, Description, MaximumCapacity, CreatedByUser)
        End Sub


        Public Overrides Function AddSession(ByVal SpeakerId As Integer, ByVal TrackId As Integer, ByVal TimeSlotId As Integer, ByVal RoomId As Integer, ByVal Title As String, ByVal Description As String, ByVal AudienceLevel As Integer, ByVal CreatedByUser As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_AddSession), SpeakerId, TrackId, TimeSlotId, RoomId, Title, Description, AudienceLevel, CreatedByUser), Integer)
        End Function
        Public Overrides Function AddSessionMinimal(ByVal SpeakerId As Integer, ByVal Title As String, ByVal Description As String, ByVal AudienceLevel As Integer, ByVal CreatedByUser As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_AddSessionMinimal), SpeakerId, Title, Description, AudienceLevel, CreatedByUser), Integer)
        End Function
        Public Overrides Sub DeleteSession(ByVal SessionId As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_DeleteSession), SessionId)
        End Sub
        Public Overrides Function GetSession(ByVal SessionId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetSession), SessionId), IDataReader)
        End Function
        Public Overrides Function GetSessionsByCodeCamp(ByVal CodeCampId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetSessionsByCodeCamp), CodeCampId), IDataReader)
        End Function
        Public Overrides Function GetSessionsByTrack(ByVal TrackId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetSessionsByTrack), TrackId), IDataReader)
        End Function
        Public Overrides Function GetSessionsBySpeakerId(ByVal SpeakerId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetSessionsBySpeakerId), SpeakerId), IDataReader)
        End Function
        Public Overrides Sub UpdateSession(ByVal SessionId As Integer, ByVal SpeakerId As Integer, ByVal TrackId As Integer, ByVal TimeSlotId As Integer, ByVal RoomId As Integer, ByVal Title As String, ByVal Description As String, ByVal AudienceLevel As Integer, ByVal CreatedByUser As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_UpdateSession), SessionId, SpeakerId, TrackId, TimeSlotId, RoomId, Title, Description, AudienceLevel, CreatedByUser)
        End Sub
        Public Overrides Sub UpdateSessionMinimal(ByVal SessionId As Integer, ByVal SpeakerId As Integer, ByVal Title As String, ByVal Description As String, ByVal AudienceLevel As Integer, ByVal CreatedByUser As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_UpdateSessionMinimal), SessionId, SpeakerId, Title, Description, AudienceLevel, CreatedByUser)
        End Sub


        Public Overrides Function AddSpeaker(ByVal RegistrationId As Integer, ByVal SpeakerName As String, ByVal CompanyTitle As String, ByVal CompanyName As String, ByVal URL As String, ByVal Bio As String, ByVal IconFile As String, ByVal MicrosoftMVP As Boolean, ByVal Author As Boolean, ByVal Approved As Boolean, ByVal CreatedByUser As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_AddSpeaker), RegistrationId, SpeakerName, CompanyTitle, CompanyName, URL, Bio, IconFile, MicrosoftMVP, Author, Approved, CreatedByUser), Integer)
        End Function
        Public Overrides Sub DeleteSpeaker(ByVal SpeakerId As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_DeleteSpeaker), SpeakerId)
        End Sub
        Public Overrides Function GetSpeaker(ByVal SpeakerId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetSpeaker), SpeakerId), IDataReader)
        End Function
        Public Overrides Function GetSpeakerByUserId(ByVal UserId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetSpeakerByUserId), UserId), IDataReader)
        End Function
        Public Overrides Function GetSpeakerByRegistrationId(ByVal RegistrationId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetSpeakerByRegistrationId), RegistrationId), IDataReader)
        End Function
        Public Overrides Function GetSpeakersByCodeCamp(ByVal CodeCampId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetSpeakersByCodeCamp), CodeCampId), IDataReader)
        End Function
        Public Overrides Function GetSpeakersByCodeCampAll(ByVal CodeCampId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetSpeakersByCodeCampAll), CodeCampId), IDataReader)
        End Function
        Public Overrides Function GetSpeakersBySession(ByVal SessionId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetSpeakersBySession), SessionId), IDataReader)
        End Function
        Public Overrides Sub UpdateSpeaker(ByVal SpeakerId As Integer, ByVal RegistrationId As Integer, ByVal SpeakerName As String, ByVal CompanyTitle As String, ByVal CompanyName As String, ByVal URL As String, ByVal Bio As String, ByVal IconFile As String, ByVal MicrosoftMVP As Boolean, ByVal Author As Boolean, ByVal Approved As Boolean, ByVal CreatedByUser As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_UpdateSpeaker), SpeakerId, RegistrationId, SpeakerName, CompanyTitle, CompanyName, URL, Bio, IconFile, MicrosoftMVP, Author, Approved, CreatedByUser)
        End Sub
        Public Overrides Sub ApproveSpeaker(ByVal SpeakerId As Integer, ByVal Approved As Boolean)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_ApproveSpeaker), SpeakerId, Approved)
        End Sub


        Public Overrides Function AddTimeSlot(ByVal CodeCampId As Integer, ByVal BeginTime As Date, ByVal EndTime As Date, ByVal AgendaText As String, ByVal SpanAllTracks As Boolean, ByVal IncludeInDropDowns As Boolean, ByVal CreatedByUser As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_AddTimeSlot), CodeCampId, BeginTime, EndTime, AgendaText, SpanAllTracks, IncludeInDropDowns, CreatedByUser), Integer)
        End Function
        Public Overrides Sub DeleteTimeSlot(ByVal TimeSlotId As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_DeleteTimeSlot), TimeSlotId)
        End Sub
        Public Overrides Function GetTimeSlot(ByVal TimeSlotId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetTimeSlot), TimeSlotId), IDataReader)
        End Function
        Public Overrides Function GetTimeSlots(ByVal CodeCampId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetTimeSlots), CodeCampId), IDataReader)
        End Function
        Public Overrides Sub UpdateTimeSlot(ByVal TimeSlotId As Integer, ByVal CodeCampId As Integer, ByVal BeginTime As Date, ByVal EndTime As Date, ByVal AgendaText As String, ByVal SpanAllTracks As Boolean, ByVal IncludeInDropDowns As Boolean, ByVal CreatedByUser As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_UpdateTimeSlot), TimeSlotId, CodeCampId, BeginTime, EndTime, AgendaText, SpanAllTracks, IncludeInDropDowns, CreatedByUser)
        End Sub


        Public Overrides Function AddTrack(ByVal CodeCampId As Integer, ByVal Title As String, ByVal Description As String, ByVal CreatedByUser As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_AddTrack), CodeCampId, Title, Description, CreatedByUser), Integer)
        End Function
        Public Overrides Sub DeleteTrack(ByVal TrackId As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_DeleteTrack), TrackId)
        End Sub
        Public Overrides Function GetTrack(ByVal TrackId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetTrack), TrackId), IDataReader)
        End Function
        Public Overrides Function GetTracks(ByVal CodeCampId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetTracks), CodeCampId), IDataReader)
        End Function
        Public Overrides Sub UpdateTrack(ByVal TrackId As Integer, ByVal CodeCampId As Integer, ByVal Title As String, ByVal Description As String, ByVal CreatedByUser As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_UpdateTrack), TrackId, CodeCampId, Title, Description, CreatedByUser)
        End Sub


        Public Overrides Function AddVolunteer(ByVal RegistrationId As Integer, ByVal Notes As String) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_AddVolunteer), RegistrationId, Notes), Integer)
        End Function
        Public Overrides Sub DeleteVolunteer(ByVal VolunteerId As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_DeleteVolunteer), VolunteerId)
        End Sub
        Public Overrides Function GetVolunteer(ByVal VolunteerId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetVolunteer), VolunteerId), IDataReader)
        End Function
        Public Overrides Function GetVolunteers(ByVal CodeCampId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetVolunteers), CodeCampId), IDataReader)
        End Function
        Public Overrides Sub UpdateVolunteer(ByVal VolunteerId As Integer, ByVal RegistrationId As Integer, ByVal Notes As String)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_UpdateVolunteer), VolunteerId, RegistrationId, Notes)
        End Sub


        Public Overrides Function AddVolunteerTask(ByVal VolunteerId As Integer, ByVal Title As String, ByVal BeginDate As Date, ByVal EndDate As Date, ByVal CreatedByUser As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_AddVolunteerTask), VolunteerId, Title, BeginDate, EndDate, CreatedByUser), Integer)
        End Function
        Public Overrides Sub DeleteVolunteerTask(ByVal VolunteerTaskId As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_DeleteVolunteerTask), VolunteerTaskId)
        End Sub
        Public Overrides Function GetVolunteerTask(ByVal VolunteerTaskId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetVolunteerTask), VolunteerTaskId), IDataReader)
        End Function
        Public Overrides Function GetVolunteerTasks(ByVal VolunteerId As Integer) As System.Data.IDataReader
            Return CType(SqlHelper.ExecuteReader(Me.ConnectionString, GetFullyQualifiedName(c_GetVolunteerTasks), VolunteerId), IDataReader)
        End Function
        Public Overrides Sub UpdateVolunteerTask(ByVal VolunteerTaskId As Integer, ByVal VolunteerId As Integer, ByVal Title As String, ByVal BeginDate As Date, ByVal EndDate As Date, ByVal CreatedByUser As Integer)
            SqlHelper.ExecuteNonQuery(Me.ConnectionString, GetFullyQualifiedName(c_UpdateVolunteerTask), VolunteerTaskId, VolunteerId, Title, BeginDate, EndDate, CreatedByUser)
        End Sub


        Public Overrides Function CodeCampCount() As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_CodeCampCount)), Integer)
        End Function
        Public Overrides Function CodeCampAttendeeCount(ByVal CodeCampId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_CodeCampAttendeeCount), CodeCampId), Integer)
        End Function
        Public Overrides Function CodeCampRoomCount(ByVal CodeCampId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_CodeCampRoomCount), CodeCampId), Integer)
        End Function
        Public Overrides Function CodeCampSessionCount(ByVal CodeCampId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_CodeCampSessionCount), CodeCampId), Integer)
        End Function
        Public Overrides Function CodeCampSpeakerCount(ByVal CodeCampId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_CodeCampSpeakerCount), CodeCampId), Integer)
        End Function
        Public Overrides Function CodeCampTrackCount(ByVal CodeCampId As Integer) As Integer
            Dim intReturn As Integer = CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_CodeCampTrackCount), CodeCampId), Integer)
            Trace.TraceWarning("SqlDataProvider: intReturn = " & intReturn)
            Return intReturn
        End Function
        Public Overrides Function CodeCampVolunteerCount(ByVal CodeCampId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_CodeCampVolunteerCount), CodeCampId), Integer)
        End Function
        Public Overrides Function CodeCampVolunteerTaskCount(ByVal CodeCampId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_CodeCampVolunteerTaskCount), CodeCampId), Integer)
        End Function
        Public Overrides Function SpeakerSessionCount(ByVal CodeCampId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_SpeakerSessionCount), CodeCampId), Integer)
        End Function
        Public Overrides Function TrackSessionCount(ByVal TrackId As Integer) As Integer
            Return CType(SqlHelper.ExecuteScalar(Me.ConnectionString, GetFullyQualifiedName(c_TrackSessionCount), TrackId), Integer)
        End Function

#End Region

#Region " Private Helper Methods "

        Private Function GetNull(ByVal Field As Object) As Object
            Return DotNetNuke.Common.Utilities.Null.GetNull(Field, DBNull.Value)
        End Function

#End Region

    End Class

End Namespace